package com.chixing.service.impl;

import com.chixing.pojo.BaseMessage;
import com.chixing.service.MessageService;
import com.chixing.util.ServerResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {
    public static final String COLLECTIONNAME_MESSAGE = "message";
    @Autowired
    MongoTemplate mongoTemplate;

    @Override
    public ServerResult getAllMsg() {

       List<BaseMessage> msgList = mongoTemplate.findAll (BaseMessage.class,COLLECTIONNAME_MESSAGE);

        System.out.println (msgList);
       if (msgList!=null&&msgList.size ()>0){
           return ServerResult.getSussess (msgList);
       }
        return null;
    }
}
